// 2025/5/27
// 差值

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for(auto& ai : a) cin >> ai;

    sort(a.begin(), a.end());
    auto ans = (long long)10e9;
    for(int i = 1; i < n; i++)
    {
        ans = min(ans, a[i] - a[i - 1]);
    }
    cout << ans << endl;
}
// 64 位输出请用 printf("%lld")